package com.yunhe.java.others;

import java.util.Scanner;

/**
 * Created by Administrator on 2017/7/19 0019.
 */
public class B {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.printf("请输入出生日期年：");
        int year1 = scanner.nextInt();
        System.out.printf("请输入出生日期月：");
        int month1 = scanner.nextInt();
        System.out.printf("请输入出生日期日：");
        int day1 = scanner.nextInt();
        System.out.printf("请输入查询日期年：");
        int year2 = scanner.nextInt();
        System.out.printf("请输入查询日期月：");
        int month2 = scanner.nextInt();
        System.out.printf("请输入查询日期日：");
        int day2 = scanner.nextInt();
        int a = calcDate(year1, month1, day1);
        System.out.println(a);
        int b = calcDate(year2, month2, day2);
        System.out.println(b);
        int sum = 0;
        int y = year2 - year1;
        y = y - 1;
        if ((year1 % 4 == 0) && (year1 % 100 != 0) || year1 % 400 == 0) {
            sum = 31 * y * 7 + 30 * 4 * y + 366 + b - a;
        } else {
            sum = 31 * y * 7 + 30 * 4 * y + 365 + b - a;
        }

        System.out.println(sum);
        int s = 0;
        for (int i = year1+1; i < year2; i++) {
            if ((i % 4 == 0) && (i % 100 != 0) || i % 400 == 0) {
                s += 29;
            } else {
                s += 28;
            }
        }
        System.out.print(sum +s+"\t");
    }


    public static int calcDate(int year, int month, int day) {
        int total = 0;
        for (int i = 1; i < month; i++) {
            int days;
            switch (i) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12: {
                    days = 31;
                }
                break;
                case 2: {
                    days = 28;
                    if ((year % 4 == 0) && (year % 100 != 0) || year % 400 == 0) {
                        days = 29;
                    }
                }
                break;
                case 4:
                case 6:
                case 9:
                case 11: {
                    days = 30;
                    break;
                }
                default:
                    days = 30;
            }

            total += days;
        }

        return total + day;
    }
}
